package com.bysj.yqsht.web.controller;


import com.bysj.yqsht.bean.CheckStudent;
import com.bysj.yqsht.bean.extend.CheckStudentExtend;
import com.bysj.yqsht.service.ICheckStudentService;
import com.bysj.yqsht.utils.Message;
import com.bysj.yqsht.utils.MessageUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("checkStudent")
@Api(description = "学生考勤管理接口")
public class CheckStudentController {
    @Autowired
    private ICheckStudentService checkStudentService;

    @GetMapping("findAll")
    public Message findAll(){
        List<CheckStudent> CheckStudent = checkStudentService.findAll();
        return MessageUtil.success(CheckStudent);
    }
    @GetMapping("findWithAll")
    public Message findWithAll(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int limit){
        List<CheckStudentExtend> list = checkStudentService.findWithAll(pageNum,limit);

        return MessageUtil.success(list);
    }
    @PostMapping("saveOrUpdete")
    public Message saveOrUpdate(CheckStudent checkStudent){
        checkStudentService.saveOrUpdate(checkStudent);
        return MessageUtil.success("新增或修改成功");
    }
    @GetMapping("deleteById")
    public Message deleteById(Long id){
        checkStudentService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
    @GetMapping("findWithAllByStudent")
    public Message findWithAllByStudent(Long student,Long classesId,String type){
       List<CheckStudentExtend> checkStudentExtends=checkStudentService.findWithAllByStudent(student,classesId,type);
        return MessageUtil.success(checkStudentExtends);
    }

}
